<template>
  <van-nav-bar
      title="标题"
      left-arrow
      @click-left="onClickLeft"
      @click-right="onClickRight"
  >
    <template #right>
      <van-icon name="search" size="18" />
    </template>
  </van-nav-bar>

  <div id="content">
    <router-view />
  </div>

  <van-tabbar route  @change="onChange">
    <van-tabbar-item to="/" icon="home-o" name="index">主页</van-tabbar-item>
    <van-tabbar-item to="/team" icon="search" name="team">队伍页</van-tabbar-item>
    <van-tabbar-item to="/user" icon="friends-o" name="user">个人</van-tabbar-item>
  </van-tabbar>

</template>

<script setup>
// <!-- vue3的语法糖 setup指定在script中定义变量会直接暴露给页面(不用写return)-->
import {showToast} from "vant";
import {useRouter} from "vue-router";

const router = useRouter();

const onClickLeft = () => {
  router.back()
}
// 点击右边的搜索实现路由的跳转
const onClickRight = () => {
  router.push('/search')
}

const onChange = (index) => showToast(`标签 ${index}`);
</script>

<style scoped>
#content{
  padding-bottom: 50px;
}
</style>